<p>By contract, the method <code>Object.wait(...)</code>, <code>Object.notify()</code> and <code>Object.notifyAll()</code> should be called by a
thread that is the owner of the object’s monitor. If this is not the case an <code>IllegalMonitorStateException</code> exception is thrown. This rule
reinforces this constraint by making it mandatory to call one of these methods only inside a <code>synchronized</code> method or statement.</p>
<h2>Noncompliant Code Example</h2>
<pre>
private void removeElement() {
  while (!suitableCondition()){
    obj.wait();
  }
  ... // Perform removal
}
</pre>
<p>or</p>
<pre>
private void removeElement() {
  while (!suitableCondition()){
    wait();
  }
  ... // Perform removal
}
</pre>
<h2>Compliant Solution</h2>
<pre>
private void removeElement() {
  synchronized(obj) {
    while (!suitableCondition()){
      obj.wait();
    }
    ... // Perform removal
  }
}
</pre>
<p>or</p>
<pre>
private synchronized void removeElement() {
  while (!suitableCondition()){
    wait();
  }
  ... // Perform removal
}
</pre>

